<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LINE 2 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LINE 6 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  System.Win32.SimpleMAPI</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) Esa Ilari Vuokko, 2006</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  BSD-style (see the file LICENSE)</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  Esa Ilari Vuokko &lt;ei@vuokko.info&gt;</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- FFI-bindings to interact with SimpleMAPI</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.SimpleMAPI</span><span>
</span><span id="line-20"></span><span class="hs-keyword">where</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-comment">-- I am not sure why exactly, but with mingw64 mapi.h does not define</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- some of the values we use, e.g. MAPI_LOGOFF_SHARED.</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- mapix.h does define MAPI_LOGOFF_SHARED, but the various flags</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- clash with each other.</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Exception</span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">bracket</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">handle</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">finally</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">onException</span><span>
</span><span id="line-28"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">IOException</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span>        </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">liftM5</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign</span><span>              </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">FunPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">newForeignPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">pokeByteOff</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">maybeWith</span><span>
</span><span id="line-31"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Ptr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">castPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">castPtrToFunPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">nullPtr</span><span>
</span><span id="line-32"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">touchForeignPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">alloca</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peek</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">allocaBytes</span><span>
</span><span id="line-33"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">minusPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">plusPtr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">copyBytes</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C</span><span>            </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">withCAString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withCAStringLen</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span>  </span><span class="hs-comment">-- Apparently, simple MAPI does not support unicode and probably never will,</span><span>
</span><span id="line-36"></span><span>  </span><span class="hs-comment">-- so this module will just mangle any Unicode in your strings</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Graphics.Win32.GDI.Types</span><span>     </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.DLL</span><span>     </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">loadLibrary</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">freeLibrary</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>   </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">DWORD</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPSTR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HMODULE</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-48"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-49"></span><span class="hs-keyword">newtype</span><span> </span><span class="hs-identifier">MapiRecipDesc</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">MapiRecipDesc</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-51"></span><span class="hs-identifier">mAPI_LOGON_UI</span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-52"></span><span class="hs-identifier">mAPI_LOGON_UI</span><span>          </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-53"></span><span class="hs-identifier">mAPI_NEW_SESSION</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-54"></span><span class="hs-identifier">mAPI_NEW_SESSION</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-55"></span><span class="hs-identifier">mAPI_FORCE_DOWNLOAD</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-56"></span><span class="hs-identifier">mAPI_FORCE_DOWNLOAD</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4096</span><span>
</span><span id="line-57"></span><span class="hs-identifier">mAPI_DIALOG</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-58"></span><span class="hs-identifier">mAPI_DIALOG</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">8</span><span>
</span><span id="line-59"></span><span class="hs-identifier">mAPI_UNREAD_ONLY</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-60"></span><span class="hs-identifier">mAPI_UNREAD_ONLY</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">32</span><span>
</span><span id="line-61"></span><span class="hs-identifier">mAPI_LONG_MSGID</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-62"></span><span class="hs-identifier">mAPI_LONG_MSGID</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">16384</span><span>
</span><span id="line-63"></span><span class="hs-identifier">mAPI_GUARANTEE_FIFO</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-64"></span><span class="hs-identifier">mAPI_GUARANTEE_FIFO</span><span>    </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">256</span><span>
</span><span id="line-65"></span><span class="hs-identifier">mAPI_ENVELOPE_ONLY</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-66"></span><span class="hs-identifier">mAPI_ENVELOPE_ONLY</span><span>     </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">64</span><span>
</span><span id="line-67"></span><span class="hs-identifier">mAPI_PEEK</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-68"></span><span class="hs-identifier">mAPI_PEEK</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">128</span><span>
</span><span id="line-69"></span><span class="hs-identifier">mAPI_BODY_AS_FILE</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-70"></span><span class="hs-identifier">mAPI_BODY_AS_FILE</span><span>      </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">512</span><span>
</span><span id="line-71"></span><span class="hs-identifier">mAPI_SUPPRESS_ATTACH</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-72"></span><span class="hs-identifier">mAPI_SUPPRESS_ATTACH</span><span>   </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2048</span><span>
</span><span id="line-73"></span><span class="hs-identifier">mAPI_AB_NOMODIFY</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-74"></span><span class="hs-identifier">mAPI_AB_NOMODIFY</span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1024</span><span>
</span><span id="line-75"></span><span class="hs-identifier">mAPI_OLE</span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-76"></span><span class="hs-identifier">mAPI_OLE</span><span>               </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-77"></span><span class="hs-identifier">mAPI_OLE_STATIC</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-78"></span><span class="hs-identifier">mAPI_OLE_STATIC</span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-79"></span><span class="hs-identifier">mAPI_UNREAD</span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-80"></span><span class="hs-identifier">mAPI_UNREAD</span><span>            </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">1</span><span>
</span><span id="line-81"></span><span class="hs-identifier">mAPI_RECEIPT_REQUESTED</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-82"></span><span class="hs-identifier">mAPI_RECEIPT_REQUESTED</span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">2</span><span>
</span><span id="line-83"></span><span class="hs-identifier">mAPI_SENT</span><span>              </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-84"></span><span class="hs-identifier">mAPI_SENT</span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="hs-number">4</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-pragma">{-# LINE 70 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- Have to define enum values outside previous declaration due to</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- hsc2hs bug in --cross-compile mode:</span><span>
</span><span id="line-72"></span><span class="hs-comment">--    https://ghc.haskell.org/trac/ghc/ticket/13620</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-pragma">{-# LINE 78 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-pragma">{-# LINE 83 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-identifier">mapiErrors</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-identifier">ULONG</span><span class="hs-special">,</span><span class="hs-identifier">String</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-85"></span><span class="hs-identifier">mapiErrors</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-86"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-special">)</span><span>         </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Success&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span class="hs-pragma">{-# LINE 87 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-87"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">2</span><span class="hs-special">)</span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Generic error or multiple errors&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span class="hs-pragma">{-# LINE 88 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-88"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">1</span><span class="hs-special">)</span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;User aborted&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span class="hs-pragma">{-# LINE 89 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-89"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">3</span><span class="hs-special">)</span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Logoff failed&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span class="hs-pragma">{-# LINE 90 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-90"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">3</span><span class="hs-special">)</span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Logon failed&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-91"></span><span class="hs-pragma">{-# LINE 91 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-91"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">4</span><span class="hs-special">)</span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Disk full&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span class="hs-pragma">{-# LINE 92 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-92"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">5</span><span class="hs-special">)</span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Not enough memory&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span class="hs-pragma">{-# LINE 93 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-93"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">6</span><span class="hs-special">)</span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Access denied&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span class="hs-pragma">{-# LINE 94 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="hs-pragma">{-# LINE 97 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-97"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Too many open sessions&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span class="hs-pragma">{-# LINE 98 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">9</span><span class="hs-special">)</span><span>   </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Too many open files&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span class="hs-pragma">{-# LINE 99 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-99"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">10</span><span class="hs-special">)</span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Too many recipients&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-pragma">{-# LINE 100 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-100"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">11</span><span class="hs-special">)</span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Attachment not found&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span class="hs-pragma">{-# LINE 101 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-101"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">12</span><span class="hs-special">)</span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Couldn't open attachment&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-pragma">{-# LINE 102 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-102"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">13</span><span class="hs-special">)</span><span> </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Couldn't write attachment&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span class="hs-pragma">{-# LINE 103 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-103"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">14</span><span class="hs-special">)</span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Unknown recipient&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="hs-pragma">{-# LINE 104 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-104"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">15</span><span class="hs-special">)</span><span>            </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Bad recipient type&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span class="hs-pragma">{-# LINE 105 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-105"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">16</span><span class="hs-special">)</span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;No messages&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span class="hs-pragma">{-# LINE 106 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-106"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">17</span><span class="hs-special">)</span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Invalid message&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span class="hs-pragma">{-# LINE 107 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-107"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">18</span><span class="hs-special">)</span><span>           </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Text too large&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span class="hs-pragma">{-# LINE 108 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-108"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">19</span><span class="hs-special">)</span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Invalid session&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span class="hs-pragma">{-# LINE 109 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">20</span><span class="hs-special">)</span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Type not supported&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span class="hs-pragma">{-# LINE 110 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">21</span><span class="hs-special">)</span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Ambigious recipient&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span class="hs-pragma">{-# LINE 111 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-pragma">{-# LINE 114 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-114"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">22</span><span class="hs-special">)</span><span>           </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Message in use&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-115"></span><span class="hs-pragma">{-# LINE 115 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-115"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">23</span><span class="hs-special">)</span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Network failure&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span class="hs-pragma">{-# LINE 116 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-116"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">24</span><span class="hs-special">)</span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Invalid editfields&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-117"></span><span class="hs-pragma">{-# LINE 117 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-117"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">25</span><span class="hs-special">)</span><span>           </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Invalid recipient(s)&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span class="hs-pragma">{-# LINE 118 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-118"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">26</span><span class="hs-special">)</span><span>            </span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;Not supported&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span class="hs-pragma">{-# LINE 119 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-119"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span class="hs-identifier">mapiErrorString</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-122"></span><span class="hs-identifier">mapiErrorString</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">lookup</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-identifier">mapiErrors</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-123"></span><span>    </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-string">&quot;Unkown error (&quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;)&quot;</span><span>
</span><span id="line-124"></span><span>    </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">x</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">x</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-identifier">mapiFail</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-127"></span><span class="hs-identifier">mapiFail</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-operator">&gt;&gt;=</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">err</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">err</span><span class="hs-operator">==</span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span class="hs-pragma">{-# LINE 128 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-128"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">err</span><span>
</span><span id="line-129"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">fail</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">mapiErrorString</span><span> </span><span class="hs-identifier">err</span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-identifier">mapiFail_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-133"></span><span class="hs-identifier">mapiFail_</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">mapiFail</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-operator">&gt;&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiLogonType</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-136"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span> </span><span class="hs-identifier">mkMapiLogon</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">MapiLogonType</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiLogonType</span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiLogoffType</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-139"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span> </span><span class="hs-identifier">mkMapiLogoff</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">MapiLogoffType</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiLogoffType</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiResolveNameType</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-142"></span><span>    </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LPSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-143"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">MapiRecipDesc</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-144"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span> </span><span class="hs-identifier">mkMapiResolveName</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">MapiResolveNameType</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiResolveNameType</span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiFreeBufferType</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-147"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span> </span><span class="hs-identifier">mkMapiFreeBuffer</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">MapiFreeBufferType</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFreeBufferType</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiSendMailType</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Message</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-150"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;dynamic&quot;</span><span> </span><span class="hs-identifier">mkMapiSendMail</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">MapiSendMailType</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiSendMailType</span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">MapiFuncs</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-153"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">mapifLogon</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiLogonType</span><span>
</span><span id="line-154"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mapifLogoff</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiLogoffType</span><span>
</span><span id="line-155"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mapifResolveName</span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiResolveNameType</span><span>
</span><span id="line-156"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mapifFreeBuffer</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFreeBufferType</span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">mapifSendMail</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiSendMailType</span><span>
</span><span id="line-158"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">MapiLoaded</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MapiFuncs</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-164"></span><span class="hs-identifier">loadMapiFuncs</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-165"></span><span class="hs-identifier">loadMapiFuncs</span><span> </span><span class="hs-identifier">dllname</span><span> </span><span class="hs-identifier">dll</span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="hs-identifier">liftM5</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-string">&quot;MAPILogon&quot;</span><span>       </span><span class="hs-identifier">dll</span><span> </span><span class="hs-identifier">mkMapiLogon</span><span class="hs-special">)</span><span>
</span><span id="line-167"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-string">&quot;MAPILogoff&quot;</span><span>      </span><span class="hs-identifier">dll</span><span> </span><span class="hs-identifier">mkMapiLogoff</span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-string">&quot;MAPIResolveName&quot;</span><span> </span><span class="hs-identifier">dll</span><span> </span><span class="hs-identifier">mkMapiResolveName</span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-string">&quot;MAPIFreeBuffer&quot;</span><span>  </span><span class="hs-identifier">dll</span><span> </span><span class="hs-identifier">mkMapiFreeBuffer</span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-string">&quot;MAPISendMail&quot;</span><span>    </span><span class="hs-identifier">dll</span><span> </span><span class="hs-identifier">mkMapiSendMail</span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-172"></span><span>       </span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-173"></span><span>       </span><span class="hs-identifier">loadProc</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-identifier">dll'</span><span> </span><span class="hs-identifier">conv</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-174"></span><span>            </span><span class="hs-identifier">proc</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIfNull</span><span> </span><span class="hs-special">(</span><span class="hs-string">&quot;loadMapiDll: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">dllname</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">name</span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>                        </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">getProcAddress</span><span> </span><span class="hs-identifier">dll'</span><span> </span><span class="hs-identifier">name</span><span>
</span><span id="line-176"></span><span>            </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">conv</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">castPtrToFunPtr</span><span> </span><span class="hs-identifier">proc</span><span>
</span><span id="line-177"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-178"></span><span class="hs-identifier">loadMapiDll</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MapiFuncs</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">HMODULE</span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span class="hs-identifier">loadMapiDll</span><span> </span><span class="hs-identifier">dllname</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-180"></span><span>    </span><span class="hs-identifier">dll</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">loadLibrary</span><span> </span><span class="hs-identifier">dllname</span><span>
</span><span id="line-181"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-identifier">funcs</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">loadMapiFuncs</span><span> </span><span class="hs-identifier">dllname</span><span> </span><span class="hs-identifier">dll</span><span>
</span><span id="line-182"></span><span>       </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">funcs</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dll</span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>     </span><span class="hs-special">`</span><span class="hs-identifier">onException</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">freeLibrary</span><span> </span><span class="hs-identifier">dll</span><span>
</span><span id="line-184"></span><span>
</span><span id="line-185"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-186"></span><span class="hs-identifier">withMapiFuncs</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">String</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MapiFuncs</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-187"></span><span class="hs-identifier">withMapiFuncs</span><span> </span><span class="hs-identifier">dlls</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">bracket</span><span> </span><span class="hs-identifier">load</span><span> </span><span class="hs-identifier">free</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">act</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">fst</span><span class="hs-special">)</span><span>
</span><span id="line-188"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-190"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">fail</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-string">&quot;withMapiFuncs: Failed to load DLLs: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">dlls</span><span>
</span><span id="line-191"></span><span>            </span><span class="hs-identifier">x</span><span class="hs-glyph">:</span><span class="hs-identifier">y</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">handleIOException</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">const</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">loadMapiDll</span><span> </span><span class="hs-identifier">x</span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span>        </span><span class="hs-identifier">load</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">dlls</span><span>
</span><span id="line-193"></span><span>        </span><span class="hs-identifier">free</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">freeLibrary</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">snd</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-196"></span><span class="hs-identifier">loadMapi</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">String</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">MapiLoaded</span><span>
</span><span id="line-197"></span><span class="hs-identifier">loadMapi</span><span> </span><span class="hs-identifier">dlls</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-198"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">f</span><span class="hs-special">,</span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">dlls</span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-identifier">m'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">newForeignPtr</span><span> </span><span class="hs-identifier">c_FreeLibraryFinaliser</span><span> </span><span class="hs-identifier">m</span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">f</span><span class="hs-special">,</span><span class="hs-identifier">m'</span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-202"></span><span>        </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">l</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-203"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">fail</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-string">&quot;loadMapi: Failed to load any of DLLs: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">dlls</span><span>
</span><span id="line-204"></span><span>            </span><span class="hs-identifier">x</span><span class="hs-glyph">:</span><span class="hs-identifier">y</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">handleIOException</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">const</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">loadOne</span><span> </span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">loadMapiDll</span><span> </span><span class="hs-identifier">x</span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="hs-pragma">{-# CFILES cbits/HsWin32.c #-}</span><span>
</span><span id="line-208"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">ccall</span><span> </span><span class="hs-string">&quot;HsWin32.h &amp;FreeLibraryFinaliser&quot;</span><span>
</span><span id="line-209"></span><span>    </span><span class="hs-identifier">c_FreeLibraryFinaliser</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FunPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HMODULE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-210"></span><span>
</span><span id="line-211"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-212"></span><span class="hs-identifier">withMapiLoaded</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiLoaded</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">MapiFuncs</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-213"></span><span class="hs-identifier">withMapiLoaded</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">f</span><span class="hs-special">,</span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">finally</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">act</span><span> </span><span class="hs-identifier">f</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">touchForeignPtr</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>
</span><span id="line-214"></span><span>
</span><span id="line-215"></span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-216"></span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">maybe</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">flip</span><span> </span><span class="hs-identifier">minusPtr</span><span> </span><span class="hs-identifier">nullPtr</span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="hs-comment">-- | Create Simple MAPI-session by logon</span><span>
</span><span id="line-219"></span><span class="hs-identifier">mapiLogon</span><span>
</span><span id="line-220"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>    </span><span class="hs-comment">-- ^ Functions loaded from MAPI DLL</span><span>
</span><span id="line-221"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span>   </span><span class="hs-comment">-- ^ Parent window, used for modal logon dialog</span><span>
</span><span id="line-222"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-comment">-- ^ Session</span><span>
</span><span id="line-223"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-comment">-- ^ Password</span><span>
</span><span id="line-224"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span>     </span><span class="hs-comment">-- ^ None, one or many flags: FORCE_DOWNLOAD, NEW_SESSION, LOGON_UI, PASSWORD_UI</span><span>
</span><span id="line-225"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">LHANDLE</span><span>
</span><span id="line-226"></span><span class="hs-identifier">mapiLogon</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">pw</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-227"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">ses</span><span>  </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_ses</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-228"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">pw</span><span>   </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_pw</span><span>  </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-229"></span><span>    </span><span class="hs-identifier">alloca</span><span>                      </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">out</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-230"></span><span>        </span><span class="hs-identifier">mapiFail_</span><span> </span><span class="hs-string">&quot;MAPILogon: &quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mapifLogon</span><span>
</span><span id="line-231"></span><span>            </span><span class="hs-identifier">f</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-identifier">hwnd</span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>            </span><span class="hs-identifier">c_ses</span><span> </span><span class="hs-identifier">c_pw</span><span> </span><span class="hs-identifier">flags</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">out</span><span>
</span><span id="line-233"></span><span>        </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">out</span><span>
</span><span id="line-234"></span><span>
</span><span id="line-235"></span><span class="hs-comment">-- | End Simple MAPI-session</span><span>
</span><span id="line-236"></span><span class="hs-identifier">mapiLogoff</span><span>
</span><span id="line-237"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-238"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LHANDLE</span><span>
</span><span id="line-239"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span>
</span><span id="line-240"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-241"></span><span class="hs-identifier">mapiLogoff</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">hwnd</span><span>
</span><span id="line-242"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">mapiFail_</span><span> </span><span class="hs-string">&quot;MAPILogoff&quot;</span><span>
</span><span id="line-243"></span><span>        </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mapifLogoff</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-identifier">hwnd</span><span class="hs-special">)</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-244"></span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">RecipientClass</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">RcOriginal</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">RcTo</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">RcCc</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">RcBcc</span><span>
</span><span id="line-247"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Eq</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Ord</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Enum</span><span class="hs-special">)</span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span class="hs-identifier">rcToULONG</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">RecipientClass</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-250"></span><span class="hs-identifier">rcToULONG</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">fromEnum</span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="hs-identifier">uLONGToRc</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ULONG</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">RecipientClass</span><span>
</span><span id="line-253"></span><span class="hs-identifier">uLONGToRc</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">toEnum</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">fromIntegral</span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">Recipient</span><span>
</span><span id="line-257"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">RecipResolve</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Recipient</span><span class="hs-special">)</span><span>
</span><span id="line-258"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">Recip</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-259"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">)</span><span>
</span><span id="line-260"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">Recipients</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-identifier">RecipientClass</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Recipient</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-261"></span><span>
</span><span id="line-262"></span><span class="hs-identifier">simpleRecip</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Recipient</span><span>
</span><span id="line-263"></span><span class="hs-identifier">simpleRecip</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">RecipResolve</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Just</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Recip</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-identifier">s</span><span>
</span><span id="line-264"></span><span>
</span><span id="line-265"></span><span class="hs-identifier">withRecipient</span><span>
</span><span id="line-266"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-267"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LHANDLE</span><span>
</span><span id="line-268"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">RecipientClass</span><span>
</span><span id="line-269"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Recipient</span><span>
</span><span id="line-270"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">MapiRecipDesc</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span>
</span><span id="line-271"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-272"></span><span class="hs-identifier">withRecipient</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">rcls</span><span> </span><span class="hs-identifier">rec</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">resolve</span><span> </span><span class="hs-string">&quot;&quot;</span><span> </span><span class="hs-identifier">rec</span><span>
</span><span id="line-273"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-274"></span><span>        </span><span class="hs-identifier">a</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-275"></span><span>            </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">rcToULONG</span><span> </span><span class="hs-identifier">rcls</span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span class="hs-pragma">{-# LINE 276 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-276"></span><span>            </span><span class="hs-identifier">act</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-277"></span><span>        </span><span class="hs-identifier">resolve</span><span> </span><span class="hs-identifier">err</span><span> </span><span class="hs-identifier">rc</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">rc</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-278"></span><span>            </span><span class="hs-identifier">Recip</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-identifier">addr</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-279"></span><span>                </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_name</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-280"></span><span>                </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">addr</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_addr</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-281"></span><span>                </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">40</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-282"></span><span class="hs-pragma">{-# LINE 282 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-282"></span><span>                    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-283"></span><span class="hs-pragma">{-# LINE 283 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-283"></span><span>                    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">c_name</span><span>
</span><span id="line-284"></span><span class="hs-pragma">{-# LINE 284 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-284"></span><span>                    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">c_addr</span><span>
</span><span id="line-285"></span><span class="hs-pragma">{-# LINE 285 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-285"></span><span>                    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">24</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span class="hs-pragma">{-# LINE 286 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-286"></span><span>                    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">32</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">nullPtr</span><span>
</span><span id="line-287"></span><span class="hs-pragma">{-# LINE 287 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-287"></span><span>                    </span><span class="hs-identifier">a</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-288"></span><span>            </span><span class="hs-identifier">RecipResolve</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-identifier">flag</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-identifier">fallback</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-289"></span><span>                </span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">&lt;-</span><span>  </span><span class="hs-identifier">alloca</span><span>          </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">res</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-290"></span><span>                        </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">name'</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-291"></span><span>                            </span><span class="hs-identifier">errn</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">mapifResolveName</span><span>
</span><span id="line-292"></span><span>                                    </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-identifier">hwnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">name'</span><span> </span><span class="hs-identifier">flag</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">res</span><span>
</span><span id="line-293"></span><span>                            </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">errn</span><span class="hs-operator">==</span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span class="hs-pragma">{-# LINE 294 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-294"></span><span>                                </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-295"></span><span>                                    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">res</span><span>
</span><span id="line-296"></span><span>                                    </span><span class="hs-identifier">v</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-297"></span><span>                                    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">mapifFreeBuffer</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">castPtr</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-298"></span><span>                                    </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Right</span><span> </span><span class="hs-identifier">v</span><span>
</span><span id="line-299"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">Left</span><span>
</span><span id="line-300"></span><span>                                    </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">err</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;, &quot;</span><span>
</span><span id="line-301"></span><span>                                    </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;:&quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">mapiErrorString</span><span> </span><span class="hs-identifier">errn</span><span>
</span><span id="line-302"></span><span>                </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-303"></span><span>                    </span><span class="hs-identifier">Left</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">fallback</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-304"></span><span>                        </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">fail</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-string">&quot;Failed to resolve any of the recipients: &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">e</span><span>
</span><span id="line-305"></span><span>                        </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">x</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">resolve</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-identifier">x</span><span>
</span><span id="line-306"></span><span>                    </span><span class="hs-identifier">Right</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">x</span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="hs-identifier">withRecipients</span><span>
</span><span id="line-309"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-310"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LHANDLE</span><span>
</span><span id="line-311"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Recipients</span><span>
</span><span id="line-312"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">MapiRecipDesc</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-314"></span><span class="hs-identifier">withRecipients</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">rec</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-identifier">rec</span><span>
</span><span id="line-315"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-316"></span><span>        </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">length</span><span> </span><span class="hs-identifier">res</span><span class="hs-operator">*</span><span class="hs-identifier">rs</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-317"></span><span>            </span><span class="hs-identifier">mapM_</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">write</span><span> </span><span class="hs-identifier">buf</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">zip</span><span> </span><span class="hs-special">[</span><span class="hs-number">0</span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">reverse</span><span> </span><span class="hs-identifier">res</span><span>
</span><span id="line-318"></span><span>            </span><span class="hs-identifier">act</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">length</span><span> </span><span class="hs-identifier">res</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-319"></span><span>        </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">res</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-identifier">c</span><span class="hs-special">,</span><span class="hs-identifier">r</span><span class="hs-special">)</span><span class="hs-glyph">:</span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withRecipient</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-identifier">r</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">w</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">x</span><span class="hs-glyph">:</span><span class="hs-identifier">res</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">y</span><span>
</span><span id="line-320"></span><span>        </span><span class="hs-identifier">rs</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">40</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-321"></span><span class="hs-pragma">{-# LINE 321 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-321"></span><span>        </span><span class="hs-identifier">write</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">off</span><span class="hs-special">,</span><span class="hs-identifier">src</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-322"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">buf'</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">plusPtr</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">off</span><span class="hs-operator">*</span><span class="hs-identifier">rs</span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>            </span><span class="hs-identifier">copyBytes</span><span> </span><span class="hs-identifier">buf'</span><span> </span><span class="hs-identifier">src</span><span> </span><span class="hs-identifier">rs</span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">FileTag</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">FileTag</span><span>
</span><span id="line-326"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">ftTag</span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-comment">-- ^ mime</span><span>
</span><span id="line-327"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ftEncoding</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-328"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span><span class="hs-identifier">defFileTag</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FileTag</span><span>
</span><span id="line-331"></span><span class="hs-identifier">defFileTag</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">FileTag</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-identifier">Nothing</span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="hs-identifier">withFileTag</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">FileTag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">FileTag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-334"></span><span class="hs-identifier">withFileTag</span><span> </span><span class="hs-identifier">ft</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-335"></span><span>    </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">32</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-336"></span><span class="hs-pragma">{-# LINE 336 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-336"></span><span>    </span><span class="hs-identifier">w</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ftTag</span><span> </span><span class="hs-identifier">ft</span><span class="hs-special">)</span><span>                        </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">tbuf</span><span class="hs-special">,</span><span class="hs-identifier">tsiz</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-337"></span><span>    </span><span class="hs-identifier">w</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ftEncoding</span><span> </span><span class="hs-identifier">ft</span><span class="hs-special">)</span><span>                   </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">ebuf</span><span class="hs-special">,</span><span class="hs-identifier">esiz</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-338"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span class="hs-pragma">{-# LINE 339 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-339"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span>       </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">tsiz</span><span>
</span><span id="line-340"></span><span class="hs-pragma">{-# LINE 340 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-340"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>       </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">tbuf</span><span>
</span><span id="line-341"></span><span class="hs-pragma">{-# LINE 341 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-341"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">esiz</span><span>
</span><span id="line-342"></span><span class="hs-pragma">{-# LINE 342 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-342"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">24</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">ebuf</span><span>
</span><span id="line-343"></span><span class="hs-pragma">{-# LINE 343 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-343"></span><span>        </span><span class="hs-identifier">act</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-344"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-345"></span><span>        </span><span class="hs-identifier">w</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-346"></span><span>            </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">nullPtr</span><span class="hs-special">,</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span>
</span><span id="line-347"></span><span>            </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">x</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">withCAStringLen</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-348"></span><span>
</span><span id="line-349"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">Attachment</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Attachment</span><span>
</span><span id="line-350"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">attFlag</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-351"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">attPosition</span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">ULONG</span><span>
</span><span id="line-352"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">attPath</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-353"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">attName</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-354"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">attTag</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">FileTag</span><span>
</span><span id="line-355"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">)</span><span>
</span><span id="line-356"></span><span class="hs-identifier">defAttachment</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Attachment</span><span>
</span><span id="line-357"></span><span class="hs-identifier">defAttachment</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Attachment</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-string">&quot;&quot;</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-identifier">Nothing</span><span>
</span><span id="line-358"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">Attachments</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">Attachment</span><span class="hs-special">]</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-identifier">withAttachments</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Attachments</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Int</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Attachment</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-361"></span><span class="hs-identifier">withAttachments</span><span> </span><span class="hs-identifier">att</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">len</span><span class="hs-operator">*</span><span class="hs-keyword">as</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">write</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">act</span><span> </span><span class="hs-identifier">len</span><span> </span><span class="hs-identifier">buf</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">att</span><span>
</span><span id="line-362"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-363"></span><span>        </span><span class="hs-keyword">as</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">40</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span class="hs-pragma">{-# LINE 364 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-364"></span><span>        </span><span class="hs-identifier">len</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">length</span><span> </span><span class="hs-identifier">att</span><span>
</span><span id="line-365"></span><span>        </span><span class="hs-identifier">write</span><span> </span><span class="hs-identifier">act'</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">act'</span><span>
</span><span id="line-366"></span><span>        </span><span class="hs-identifier">write</span><span> </span><span class="hs-identifier">act'</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">att'</span><span class="hs-glyph">:</span><span class="hs-identifier">y</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-367"></span><span>            </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">attPath</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">path</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-368"></span><span>            </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withFileTag</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">attTag</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">tag</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-369"></span><span>            </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">attPath</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">id</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">attName</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">name</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-370"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-371"></span><span class="hs-pragma">{-# LINE 371 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-371"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span>       </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">attFlag</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span>
</span><span id="line-372"></span><span class="hs-pragma">{-# LINE 372 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-372"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybe</span><span> </span><span class="hs-number">0xffffffff</span><span> </span><span class="hs-identifier">id</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">attPosition</span><span> </span><span class="hs-identifier">att'</span><span class="hs-special">)</span><span>
</span><span id="line-373"></span><span class="hs-pragma">{-# LINE 373 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-373"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">path</span><span>
</span><span id="line-374"></span><span class="hs-pragma">{-# LINE 374 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-374"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">24</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">name</span><span>
</span><span id="line-375"></span><span class="hs-pragma">{-# LINE 375 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-375"></span><span>                </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">32</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">tag</span><span>
</span><span id="line-376"></span><span class="hs-pragma">{-# LINE 376 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-376"></span><span>                </span><span class="hs-identifier">write</span><span> </span><span class="hs-identifier">act'</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">plusPtr</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-keyword">as</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">y</span><span>
</span><span id="line-377"></span><span>
</span><span id="line-378"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">Message</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Message</span><span>
</span><span id="line-379"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">msgSubject</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-380"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgBody</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-381"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgType</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-382"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgDate</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-383"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgConversationId</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-384"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgFlags</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFlag</span><span>
</span><span id="line-385"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgFrom</span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">Recipient</span><span>
</span><span id="line-386"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgRecips</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Recipients</span><span>
</span><span id="line-387"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">msgAttachments</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Attachments</span><span>
</span><span id="line-388"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">)</span><span>
</span><span id="line-389"></span><span>
</span><span id="line-390"></span><span class="hs-identifier">defMessage</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Message</span><span>
</span><span id="line-391"></span><span class="hs-identifier">defMessage</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Message</span><span> </span><span class="hs-string">&quot;&quot;</span><span> </span><span class="hs-string">&quot;&quot;</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span class="hs-identifier">withMessage</span><span>
</span><span id="line-394"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span>
</span><span id="line-395"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LHANDLE</span><span>
</span><span id="line-396"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Message</span><span>
</span><span id="line-397"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">Message</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-399"></span><span class="hs-identifier">withMessage</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">m</span><span> </span><span class="hs-identifier">act</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-400"></span><span>    </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgSubject</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>             </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">subject</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-401"></span><span>    </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgBody</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>                </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">body</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-402"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgType</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>      </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">message_type</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-403"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgDate</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>      </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">date</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-404"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-identifier">withCAString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgConversationId</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">conv_id</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-405"></span><span>    </span><span class="hs-identifier">withRecipients</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgRecips</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>          </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">rlen</span><span> </span><span class="hs-identifier">rbuf</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-406"></span><span>    </span><span class="hs-identifier">withAttachments</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgAttachments</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>      </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">alen</span><span> </span><span class="hs-identifier">abuf</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-407"></span><span>    </span><span class="hs-identifier">maybeWith</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">withRecipient</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">RcOriginal</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgFrom</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">from</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-408"></span><span>    </span><span class="hs-identifier">allocaBytes</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-number">96</span><span class="hs-special">)</span><span class="hs-special">)</span><span>             </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-409"></span><span class="hs-pragma">{-# LINE 409 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-409"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span class="hs-pragma">{-# LINE 410 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-410"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">subject</span><span>
</span><span id="line-411"></span><span class="hs-pragma">{-# LINE 411 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-411"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">body</span><span>
</span><span id="line-412"></span><span class="hs-pragma">{-# LINE 412 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-412"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">24</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">message_type</span><span>
</span><span id="line-413"></span><span class="hs-pragma">{-# LINE 413 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-413"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">32</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">date</span><span>
</span><span id="line-414"></span><span class="hs-pragma">{-# LINE 414 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-414"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">40</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">conv_id</span><span>
</span><span id="line-415"></span><span class="hs-pragma">{-# LINE 415 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-415"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">48</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">msgFlags</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span>
</span><span id="line-416"></span><span class="hs-pragma">{-# LINE 416 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-416"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">56</span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">from</span><span>
</span><span id="line-417"></span><span class="hs-pragma">{-# LINE 417 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-417"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">64</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">rlen</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ULONG</span><span class="hs-special">)</span><span>
</span><span id="line-418"></span><span class="hs-pragma">{-# LINE 418 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-418"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">72</span><span class="hs-special">)</span><span class="hs-special">)</span><span>       </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">rbuf</span><span>
</span><span id="line-419"></span><span class="hs-pragma">{-# LINE 419 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-419"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">80</span><span class="hs-special">)</span><span class="hs-special">)</span><span>     </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">alen</span><span>
</span><span id="line-420"></span><span class="hs-pragma">{-# LINE 420 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-420"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">88</span><span class="hs-special">)</span><span class="hs-special">)</span><span>        </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">abuf</span><span>
</span><span id="line-421"></span><span class="hs-pragma">{-# LINE 421 &quot;libraries\\Win32\\System\\Win32\\SimpleMAPI.hsc&quot; #-}</span><span>
</span><span id="line-421"></span><span>        </span><span class="hs-identifier">act</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-422"></span><span>
</span><span id="line-423"></span><span class="hs-identifier">mapiSendMail</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">MapiFuncs</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">LHANDLE</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Maybe</span><span> </span><span class="hs-identifier">HWND</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Message</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">MapiFlag</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-424"></span><span class="hs-identifier">mapiSendMail</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">hwnd</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-identifier">flag</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withMessage</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-identifier">msg</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">c_msg</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-425"></span><span>    </span><span class="hs-identifier">mapiFail_</span><span> </span><span class="hs-string">&quot;MAPISendMail&quot;</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">mapifSendMail</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">ses</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">maybeHWND</span><span> </span><span class="hs-identifier">hwnd</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">c_msg</span><span> </span><span class="hs-identifier">flag</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="hs-identifier">handleIOException</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">IOException</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-428"></span><span class="hs-identifier">handleIOException</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">handle</span><span>
</span><span id="line-429"></span></pre></body></html>